<template>
  <div>
    <el-form :inline="true" :model="queryParams" ref="queryParams" class="demo-form-inline">
      <el-form-item label="岗位编码">
        <el-input v-model="queryParams.postCode" placeholder="请输入岗位编码" clearable></el-input>
      </el-form-item>
      <el-form-item label="岗位名称">
        <el-input v-model="queryParams.postName" placeholder="请输入岗位名称" clearable></el-input>
      </el-form-item>
      <el-form-item label="状态">
        <el-select v-model="queryParams.status" placeholder="岗位状态">
          <el-option :label="item.dictLabel" :value="item.dictValue" v-for="item in dictDataList"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" @click="search">搜索</el-button>
        <el-button type="primary" icon="el-icon-refresh" @click="resetQueryParams">重置</el-button>
      </el-form-item>
    </el-form>
    <el-button @click="handleAdd" icon="el-icon-plus" type="primary" size="small">新增</el-button>
    <el-button @click="handleDelByIds" icon="el-icon-delete" type="primary" size="small" :disabled="flag">删除</el-button>
    <el-table
        ref="multipleTable"
        :data="tableData"
        tooltip-effect="dark"
        style="width: 100%"
        @selection-change="handleSelectionChange">
      <el-table-column
          type="selection"
          width="55">
      </el-table-column>
      <el-table-column
          prop="postId"
          label="岗位编号">
      </el-table-column>
      <el-table-column
          prop="postCode"
          label="岗位编码">
      </el-table-column>
      <el-table-column
          prop="postName"
          label="岗位名称">
      </el-table-column>
      <el-table-column
          prop="postSort"
          label="岗位排序">
      </el-table-column>
      <el-table-column
          prop="status"
          label="状态">
        <template v-slot="scope">
          {{scope.row.status==0?'正常':'停用'}}
        </template>
      </el-table-column>
      <el-table-column
          prop="createTime"
          label="创建时间">
      </el-table-column>
      <el-table-column
          fixed="right"
          label="操作"
          width="100">
        <template v-slot="scope">
          <el-button @click="handleUpdate(scope.row.dictId)" type="text" size="small">修改</el-button>
          <el-button @click="handleDel(scope.row.dictId)" type="text" size="small">删除</el-button>
        </template>
      </el-table-column>
    </el-table>
    <el-pagination
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="current"
        :page-sizes="[10, 20, 30, 40]"
        :page-size="size"
        layout="total, sizes, prev, pager, next, jumper"
        :total="total">
    </el-pagination>
  </div>
</template>

<script>
export default {
  name: "PostIndexView",
  data(){
    return{
      queryParams:{},
      dictDataList:[],
      tableData:[],
      current:1,
      size:10,
      total:0,
      ids:''
    }
  },methods:{
    handleAdd(){

    },
    handleDelByIds(){

    },
    handleUpdate(postId){

    },
    handleDel(postId){

    },
    resetQueryParams(){
      this.queryParams={}
      this.search()
    },
    search(){
      this.axios.post("post/post/list?size="+this.size+"&current="+this.current,this.queryParams).then(res=>{
        this.tableData=res.data.data.records
        this.total=res.data.data.total
      })
    },
    handleSelectionChange(selection) {
      this.ids=selection.map(item => item.dictId).join(",")
    },
    handleSizeChange(size) {
      this.size=size
      this.search()
    },
    handleCurrentChange(page) {
      this.current=page
      this.search()
    }
  },created() {
    this.axios.get("/dict/dict/data/getDataByType?dictType=sys_normal_disable").then(res=>{
      this.dictDataList=res.data.data
    })
    this.search();
  }
}
</script>

<style scoped>

</style>